<#assign _topPage=true>
<#include '/pages/taglib/core.ftl'>
<#include '/pages/taglib/common.ftl'>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<#assign us = fn.service('user')>
<#assign currentWebsite = us.currentWebsite?if_exists.name!''>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
		<title><@i18n name="site." + currentWebsite/></title>
    </head>
<body>
<@header topPage=_topPage/>
<div id="loginCtn">
	<@css src="/static/espirit/styles/user.login.css" async=false/>

	<script>
		when('fixPlaceholderDefect', function() {
			if ($('#mainCtn').length > 0) {
				// the login page is loaded by the main container
				$('body').html($('#loginCtn').html());
			}
			
			var bro = $.browser;
			var binfo = "";
		    if (bro.msie) { 
		    	binfo = "IE " + bro.version;
		    	if (bro.version < 9) {
		    		$('.browserVersionWarning').show();
		    		$('#browserVersion').addClass('warningColor')
		    	}
		    }
		    if (bro.mozilla) {binfo = "Firefox " + bro.version;}
		    if (bro.safari) {binfo = "Safari " + bro.version;}
		    if (bro.opera) {binfo = "Opera " + bro.version;}
		    $('#browserVersion').html(binfo);
		    
			var screenWH = window.screen.width + '*' + window.screen.height;
			$('#screenWidthHeight').html(screenWH);
			if (window.screen.width < 1280 || window.screen.height < 800) {
				$('#screenDesc').css('color','red');
				$('#screenDesc').css('font-size','14px');
				$('#screenDesc').css('font-weight','bold');
			}
			
			
			var minHeight = $('.loginContainer').height();
			var winHeight = $(window).height();
			if (winHeight < minHeight + 40) {
				$('.loginFooter').css('top', (minHeight + 5) + 'px');
			} else {
				$('.loginFooter').css('top', (winHeight - 100) + 'px');
			}
			
			if (window.location.href.startsWith('https://')) {
				$('.userBrowserError').show();
			}
			
			var $input = $('input');
			$input.keypress(function(event) {
				if (event.which == 13) {
					login(this);
				}
			});
			$input.eq(0).focus();
			fixPlaceholderDefect($input.eq(0));
		});	
	
		function login(btnObj) {
			/*if (Notifier.hasSupport()) {
				Notifier.requestPermission(function(ret) {
					var notification = Notifier.notify("", "Notifier", "Hello Desktop!");
					notification.onclick = function (){
						notification.close();
					}
				});
			}*/
			
			var $form = $(btnObj).closest('.jform');
			
			ajaxSubmit($form, {
				beforeSend: function() {
					addLoading($('.loginInputContainer'));
				},
				success:function(data) {
					removeLoading($('.loginInputContainer'));
					var $data = $(data);
					if ($data.hasClass('error')) {
						var left = Math.floor(($(window).width() - 265)/ 2)
						showError($data.html(), 265, left + 'px', '180px');
					} else {
						//window.location='${base}/index.html';
						$('body').html(data);
					}
				}
			});
		}
	</script>

	<@form name='loginForm' action='/$/espirit/eap/sa/user.login.html'>
	
<#attempt>
	<#-- force the '_login' method is called -->
	<#assign tmp = us._login(productLogin!, productLoginDesc!)>
	<div class="loginContainer">
		<div class="loginTitle">${productLogin!}</div>
		<div class="loginProduct">${productLoginDesc!}</div>
		<div class="browserVersionWarning">
			IE版本过低，部份功能无法正常使用，请更新<a href="http://windows.microsoft.com/zh-cn/internet-explorer/download-ie" target="_blank">IE</a>，或者换用其它浏览器
		</div>
		<div class="loginInputContainer">
			<input type="text" name="name" class="loginInput" placeholder="<@i18n name='用户名'/>">
			<input type="password" name="password" class="loginInput" placeholder="<@i18n name='密码'/>">
			<input type="hidden" name="site" value="${site!'espirit'}"/>
	
			<div style="text-align: left;height: 40px;">
				<button class="button loginButton" style="float:left;" type="button" onclick="login(this)"><@i18n name="action.login"/></button>
				<a href="${fn.link('/$/espirit/eap/sa/user._forgetPassword')}" id="resetPassword"><@i18n name="login.forgotPassword"/>?</a>
			</div>
		</div>
		<div class="userBrowserError">
			如果'证书错误'请点击继续浏览
		</div>
	</div>
<#recover>
	<#include '/view/page.undefined.ftl'>
</#attempt>
		
	<div class="loginFooter">
		<div class="loginDesc">
			请使用<a href="http://www.firefox.com.cn/download/" target="_blank">Firefox</a>,
			  <a href="http://www.google.cn/intl/zh-CN/chrome/browser/" target="_blank">Chrome</a>,
			  <a href="http://safari.softonic.cn/" target="_blank">Safari</a>,
			  <a href="http://www.opera.com/zh-cn/" target="_blank">Opera</a>, 
			   <a href="http://windows.microsoft.com/zh-cn/internet-explorer/download-ie" target="_blank">IE</a>(9以上),
			  访问本系统，最佳(小)分辨率为1280*800
		</div>
		<div class="userBrowserDesc">
			当前的浏览器为<span id="browserVersion"></span>, <span id="screenDesc">屏幕分辨率为<span id="screenWidthHeight"></span></span>
		</div>
	</div>
	
	</@form>	
</div>

<@footer/>
</body>
</html>